// Programming_Scala/src/ch12/func2-script.scala
// WON'T COMPILE

class CSuper {
  def msuper = println( "CSuper" )
}
class C extends CSuper {
  def m = println( "C" )
}
class CSub extends C {
  def msub = println( "CSub" )
}

def useF( f: C => C ) = {
  val c1 = new C
  val c2: C = f( c1 )
  c2.msuper
  c2.m
}

useF( ( c: C ) => new C )
useF( ( c: CSuper ) => new CSub )
useF( ( c: CSub ) => { println( c.msub ); new CSuper } )
